<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/5/2
  Time: 14:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--解析表达式--%>
<%@ page isELIgnored="false" %>
<%--引入jstl--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--引入springMVC form--%>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="page" uri="/xianzhiOA/pageTag" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>编辑工作量概况</title>
    <script type="application/javascript">
        function check() {
            var e = 0;
            for (var a=0;a<7;a++){
                var workPlan = document.getElementById("p"+a);
                var divPlan = document.getElementById("d"+a);
                var workActual = document.getElementById("a"+a);
                var divActual = document.getElementById("da"+a);
                if (workPlan.value == "") workPlan.value = 0;
                var t = workPlan.value;
                var z= /^[0-9]*[.]*[0-9]*$/;
                if(z.test(t)){
                    if (parseInt(t)<0||parseInt(t)>24){
                        divPlan.innerHTML = "时间必须为0到24之间";
                        e++;
                    }
                }else{
                    divPlan.innerHTML = "时间只能为数字";
                    e++;
                }
                if (workActual != null){
                    var k = workActual.value;
                    if (z.test(k)) {
                        if (parseInt(k) < 0 || parseInt(k) > 24) {
                            divActual.innerHTML = "时间必须为0到24之间";
                            e++;
                        }
                    } else {
                        divActual.innerHTML = "时间只能为数字";
                        e++;
                    }
                }
            }
            if (e>0){
                return false;
            }else return true;
        }
        function go() {
            if (${week.weekId!=0}){
                document.getElementById("weekForm").action = "${pageContext.request.contextPath}/Week/updateWeek.emp";
            }
        }
        function ShowPage() {
            window.location.href = "${pageContext.request.contextPath}/Week/selWeekAll.emp";
        }
    </script>
</head>
<body>
<!--头部开始-->
<jsp:include page="headerBack.jsp"></jsp:include>
<!-- 导航 -->
<jsp:include page="leftBack.jsp"></jsp:include>
<!--内容页-->
<div class="main">
    <!--内容页头部-->
    <div class="page-header">
        <div class="pull-left">
            <ol class="breadcrumb visible-sm visible-md visible-lg">
                <li><a href="${pageContext.request.contextPath}/Login/goHomePage"><i class="icon fa fa-home"></i>主页</a></li>
                <li class="active"><i class="fa fa-pencil"></i>基本信息</li>
            </ol>
        </div>
        <div class="pull-right">
            <h2>主页</h2>
        </div>
    </div>
    <div class="row profile">
        <div class="col-lg-11">
            <div class="col-lg-7 col-md-9 col-sm-12">
                <div class="panel">
                    <div class="panel-body">
                        <div class="tabs tabs-warning">
                            <ul class="nav nav-tabs">
                                <li class="active">
                                    <a href="#edit" data-toggle="tab">编辑工作量信息</a>
                                </li>
                            </ul>
                            <div class="tab-content">
                                <div id="edit" class="tab-pane updateProfile active">
                                    <sf:form id="weekForm" action="${pageContext.request.contextPath}/Week/addWeek.emp" modelAttribute="week" method="post" class="form-horizontal" onSubmit="return check();">
                                        <div class="bk-bg-white bk-padding-top-10 bk-padding-bottom-10">
                                            <fieldset>
                                                <div class="form-group">
                                                    <sf:input type="hidden" path="weekId"/>
                                                    <label>周期</label>
                                                    <input name="weekString" type="text" class="sang_Calender"
                                                           value="<fmt:formatDate value="${week.weekTime}" pattern="yyyy-MM-dd HH:mm:ss" />" />
                                                    <span style="color: red">${errors.weekTime}</span>
                                                </div>
                                                <table>
                                                    <tr>
                                                        <td>
                                                            <label>归属名称</label>
                                                            <sf:select path="weekProject" cssStyle="width: 160px">
                                                                <sf:options items="${projectList}" itemLabel="projectName" itemValue="projectId"/>
                                                            </sf:select>
                                                        </td>
                                                        <td>
                                                            <c:if test="${userLogin.empRole.equals('1')}">
                                                                <label>负责人</label>
                                                                <sf:select path="empId">
                                                                    <sf:options items="${empList}" itemLabel="empName" itemValue="empId"/>
                                                                </sf:select>
                                                            </c:if>
                                                        </td>
                                                    </tr>
                                                <c:forEach begin="0" end="6" var="i">
                                                    <sf:input path="workList[${i}].workId" type="hidden"/>
                                                        <tr>
                                                            <td>
                                                        <label>
                                                            <c:if test="${i==0}">周一计划（小时）</c:if>
                                                            <c:if test="${i==1}">周二计划（小时）</c:if>
                                                            <c:if test="${i==2}">周三计划（小时）</c:if>
                                                            <c:if test="${i==3}">周四计划（小时）</c:if>
                                                            <c:if test="${i==4}">周五计划（小时）</c:if>
                                                            <c:if test="${i==5}">周六计划（小时）</c:if>
                                                            <c:if test="${i==6}">周日计划（小时）</c:if>
                                                        </label>
                                                        <sf:input id="p${i}" path="workList[${i}].workPlan" style="width: 100px"/>
                                                            <td>
                                                        <c:if test="${userLogin.empRole.equals('1')}">
                                                            <label>
                                                                <c:if test="${i==0}">周一实际（小时）</c:if>
                                                                <c:if test="${i==1}">周二实际（小时）</c:if>
                                                                <c:if test="${i==2}">周三实际（小时）</c:if>
                                                                <c:if test="${i==3}">周四实际（小时）</c:if>
                                                                <c:if test="${i==4}">周五实际（小时）</c:if>
                                                                <c:if test="${i==5}">周六实际（小时）</c:if>
                                                                <c:if test="${i==6}">周日实际（小时）</c:if>
                                                            </label>
                                                            <sf:input id="a${i}" path="workList[${i}].workActual" style="width: 100px"/><br/>
                                                        </c:if>
                                                            </td>
                                                        </tr>
                                                    <tr>
                                                        <td><span id="d${i}" style="color: red"></span></td></td>
                                                        <td><span id="da${i}" style="color:red;"></span></td>
                                                    </tr>
                                                </c:forEach>
                                                </table>
                                    </fieldset>
                                    <div class="bk-bg-white">
                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="pull-right">
                                                    <button onclick="go()" type="submit" class="btn btn-primary">提交</button>&nbsp;&nbsp;
                                                    <button type="button" onclick="ShowPage()" class="btn btn-primary">取消</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                </sf:form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath}/dist/backEnd/js/datetime.js"></script>
</body>
</html>
